home *** CD-ROM | disk | FTP | other *** search
- /* TrackInit.c */
- /*
- * Copyright © 1989 Martin Minow. All rights reserved.
- *
- * void
- * TrackInit()
- *
- * TrackHandle
- * TrackNew(dest, view)
- * Rect *dest;
- * Rect *view;
- *
- * void
- * TrackDispose(track_handle)
- * TrackHandle track_handle;
- *
- * Initialize, create, and destroy TrackRecords.
- */
- #include "TrackEdit.h"
- #define TR (*tr)
-
- /*
- * Track library private data.
- */
- Handle TrackScrpHandle; /* Track Scrap */
- LONGINT TrackScrpLength; /* Scrap length */
-
- void
- TrackInit()
- {
- TrackScrpHandle = NewHandle(0);
- TrackScrpLength = 0;
- }
-
- TrackHandle
- TrackNew(line_width, viewRectp)
- INTEGER line_width;
- Rect *viewRectp;
- {
- TrackHandle track_handle;
- TrackPtr tr;
- register char *ptr;
- register int i;
- FontInfo info;
- Handle temp;
-
- track_handle =
- (TrackHandle) NewHandle(sizeof (TrackRecord));
- /*
- * Initialize the record by clearing out all fields.
- * Note that we can't call _Track_lock here.
- */
- HLock(track_handle);
- tr = (*track_handle);
- ptr = (char *) tr;
- for (i = 0; i < sizeof (TrackRecord); i++)
- *ptr++ = 0;
- TR.inPort = thePort;
- TR.hText = NewHandle(0L);
- /*
- * Test whether the ScriptManager is installed,
- * Note that the ROMS must not change while the
- * program is running.
- */
- #define Unimplemented 0x9F
- #define ScriptUtil 0xB5
- if ((GetTrapAddress(Unimplemented)
- != GetTrapAddress(ScriptUtil))
- && GetEnvirons(smEnabled)) {
- _Track_set(tr, _Track_has_script_manager);
- _Track_set(tr, _Track_use_script_manager);
- _Track_set(tr, _Track_use_smart_cut_paste);
- }
- TR.lineWidth = line_width;
- TR.viewRect = *viewRectp;
- TR.txFont = thePort->txFont;
- TR.txFace = thePort->txFace;
- TR.txMode = thePort->txMode;
- TR.txSize = thePort->txSize;
- GetFontInfo(&info);
- TR.fontAscent = info.ascent;
- TR.fontDescent = info.descent;
- TR.lineHeight =
- info.ascent + info.descent + info.leading;
- HUnlock(track_handle);
- return (track_handle);
- }
-
- void
- TrackDispose(track_handle)
- TrackHandle track_handle;
- {
- DisposHandle((*track_handle)->hText);
- DisposHandle(track_handle);
- }
-
-